package com.example.idachuappone.index.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.idachuappone.R;
import com.example.idachuappone.person.entity.QuanResults;
import java.util.List;

public class AdapterYouHui extends BaseAdapter {
    private Context context;
    private List<QuanResults> list;

    private class ViewHolder {
        LinearLayout ll_quan_bg;
        TextView tv_price;
        TextView tv_quan_name;
        TextView tv_time_to;

        private ViewHolder() {
        }
    }

    public void setList(List<QuanResults> list) {
        this.list = list;
    }

    public AdapterYouHui(Context context) {
        this.context = context;
    }

    public int getCount() {
        return this.list == null ? 0 : this.list.size();
    }

    public Object getItem(int position) {
        return this.list == null ? null : (QuanResults) this.list.get(position);
    }

    public long getItemId(int position) {
        return (long) position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LinearLayout.inflate(this.context, R.layout.simple_my_youhui_list, null);
            holder.tv_quan_name = (TextView) convertView.findViewById(R.id.tv_quan_name);
            holder.tv_time_to = (TextView) convertView.findViewById(R.id.tv_time_to);
            holder.tv_price = (TextView) convertView.findViewById(R.id.tv_price);
            holder.ll_quan_bg = (LinearLayout) convertView.findViewById(R.id.ll_quan_bg);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Typeface typeface = Typeface.createFromAsset(this.context.getAssets(), "fonts/Helvetica LT 25 Ultra Light.ttf");
        holder.tv_price.getPaint().setFakeBoldText(true);
        holder.tv_price.setTypeface(typeface);
        int price = Integer.parseInt(((QuanResults) this.list.get(position)).getCoupon().getDiscount());
        if (price >= 100) {
            holder.tv_price.setTextSize(46.0f);
        } else {
            holder.tv_price.setTextSize(70.0f);
        }
        holder.tv_price.setText(new StringBuilder(String.valueOf(price)).toString());
        if (Integer.parseInt(((QuanResults) this.list.get(position)).getStatus()) == 1) {
            if (price >= 100) {
                holder.ll_quan_bg.setBackgroundResource(R.drawable.box_3num);
            } else {
                holder.ll_quan_bg.setBackgroundResource(R.drawable.img_youhui_item_bg_list);
            }
            holder.tv_price.setTextColor(Color.parseColor("#ffffff"));
            holder.tv_time_to.setTextColor(Color.parseColor("#ffffff"));
            holder.tv_quan_name.setTextColor(Color.parseColor("#574a13"));
            holder.tv_time_to.setText(new StringBuilder(String.valueOf(((QuanResults) this.list.get(position)).getTo())).append("  \u8fc7\u671f").toString());
        } else if (Integer.parseInt(((QuanResults) this.list.get(position)).getStatus()) == 2 || Integer.parseInt(((QuanResults) this.list.get(position)).getStatus()) == 3) {
            if (price >= 100) {
                holder.ll_quan_bg.setBackgroundResource(R.drawable.box_3num_used);
            } else {
                holder.ll_quan_bg.setBackgroundResource(R.drawable.img_youhui_item_bg_list_ed);
            }
            holder.tv_price.setTextColor(Color.parseColor("#eeeeee"));
            holder.tv_time_to.setTextColor(Color.parseColor("#eeeeee"));
            holder.tv_quan_name.setTextColor(Color.parseColor("#717171"));
            holder.tv_time_to.setText(new StringBuilder(String.valueOf(((QuanResults) this.list.get(position)).getTo())).append("  \u5df2\u4f7f\u7528").toString());
        } else if (Integer.parseInt(((QuanResults) this.list.get(position)).getStatus()) == 4) {
            if (price >= 100) {
                holder.ll_quan_bg.setBackgroundResource(R.drawable.box_3num_used);
            } else {
                holder.ll_quan_bg.setBackgroundResource(R.drawable.img_youhui_item_bg_list_ed);
            }
            holder.tv_price.setTextColor(Color.parseColor("#eeeeee"));
            holder.tv_time_to.setTextColor(Color.parseColor("#eeeeee"));
            holder.tv_quan_name.setTextColor(Color.parseColor("#717171"));
            holder.tv_time_to.setText(new StringBuilder(String.valueOf(((QuanResults) this.list.get(position)).getTo())).append("  \u5df2\u8fc7\u671f").toString());
        }
        holder.tv_quan_name.setText(((QuanResults) this.list.get(position)).getCoupon().getName());
        return convertView;
    }
}
